package cobots.swarm.agents;

import java.awt.geom.Point2D;

import cobots.swarm.main.SwarmState;


public class Target extends Agent {
	double angle = Math.random() * Math.PI * 2;
	
	public float x = (float)(Math.random()*SwarmState.width-SwarmState.width/2), y = (float)(Math.random()*SwarmState.height-SwarmState.height/2);//(float)(250 * Math.cos(angle)), y = (float)(250 * Math.sin(angle));
	public float creationTime = 0;
	public float reactionTime = 0;
	private static short count = 0;
	private short id = count++;
	private short leaderId = -1;
	
	public Target() {
		super(0,0,1,1);
		this.creationTime = SwarmState.currentTime;
	}
	
	public Target(short id) {
		super(0,0,1,1);
		this.id = id;
		
	}
	
	@Override
	public double getX() {
		return x;
	}
	
	@Override
	public double getY() {
		return y;
	}
	
	@Override
	public void setLocation(double x, double y) {
		this.x = (float)x;
		this.y = (float)y;
	}
	
	@Override
	public void setLocation(Point2D p) {
		if (p != null)
			setLocation(p.getX(), p.getY());
	}
	
	public short getId() {
		return id;
	}

	public void setId(short id) {
		this.id = id;
	}

	public short getLeaderId() {
        return leaderId;
    }

    public void setLeaderId(short leaderId) {
        this.leaderId = leaderId;
    }

	@Override
	public String toString() {
		return("T["+id+" "+x+" "+y+"]");
	}
}
